package zero.tech.games.log.mapper;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Select;

import zero.tech.games.entity.log.LogWaterTeam;
import zero.tech.games.log.data.TmpEntity;

public interface LogWaterTeamMapper {

	void insertBatch(List<LogWaterTeam> list);

	@Select("select count(1) from log_water_team where club_id=#{club_id} and uid=#{uid} and create_stamp between #{begin} and #{end}")
	int totalCount(int club_id, int uid, Date begin, Date end);
	
	@Select("select * from log_water_team where club_id=#{club_id} and uid=#{uid} and create_stamp between #{begin} and #{end} limit #{start},#{pageLength}")
	List<LogWaterTeam> listWaterTeamByPage(int club_id, int uid, int start, int pageLength, Date begin, Date end);

	@Select("select count(1) from log_water_team where club_id=#{club_id} and uid=#{uid} and direct=1 and create_stamp between #{begin} and #{end}")
	int totalZsCount(int club_id, int uid, Date begin, Date end);

	@Select("select * from log_water_team where club_id=#{club_id} and uid=#{uid} and direct =1 and create_stamp between #{begin} and #{end} limit #{start},#{pageLength}")
	List<LogWaterTeam> listWaterTeamZsByPage(int club_id, int uid, int start, int pageLength, Date begin, Date end);

	@Select("select count(1) from log_water_team where club_id=#{club_id} and uid=#{uid} and direct=0 and create_stamp between #{begin} and #{end}")
	int totalFzsCount(int club_id, int uid, Date begin, Date end);

	@Select("select * from log_water_team where club_id=#{club_id} and uid=#{uid} and direct =0 and create_stamp between #{begin} and #{end} limit #{start},#{pageLength}")
	List<LogWaterTeam> listWaterTeamFzsByPage(int club_id, int uid, int start, int pageLength, Date begin, Date end);

	@Select("select ifnull(sum(water),0) as total_water,ifnull(sum(water_effect),0) as total_water_effect "
			+ "from log_water_team where club_id=#{club_id} and uid=#{uid} and direct=1 "
			+ "and create_stamp between #{begin} and #{end}")
	TmpEntity totalZsWater(int club_id, int uid, Date begin, Date end);

	@Select("select count(1) from log_water_team where club_id=#{club_id} and uid=#{uid} and other_uid=#{other_uid} and direct=1 and create_stamp between #{begin} and #{end}")
	int totalZsCountByUid(int club_id, int uid, Date begin, Date end, Integer other_uid);

	@Select("select * from log_water_team where club_id=#{club_id} and uid=#{uid} and other_uid=#{other_uid} and direct=1 and create_stamp between #{begin} and #{end} limit #{start},#{pageLength}")
	List<LogWaterTeam> listWaterTeamByPageAndUid(int club_id, int uid, int start, int pageLength, Date begin, Date end, Integer other_uid);


}
